package com.mop.core.es.dao.plugins.index;

import com.alibaba.fastjson.JSONObject;
import com.lemon.core.common.lang.util.StringUtils;

/**
 * @author lemon
 * @ClassName Settings
 * @desc 修改分片和副本数的
 * @Date 2019/1/5 13:14
 * @Version 1.0
 **/
public class Settings {

    /**
     * settings 标识
     */
    private String uuid;

    /**
     * 刷新时间
     */
    private String refreshInterval;

    /**
     * 分片数
     */
    private String numberOfShards;

    /**
     * 副本数
     */
    private String numberOfReplicas;

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getRefreshInterval() {
        return refreshInterval;
    }

    public void setRefreshInterval(String refreshInterval) {
        this.refreshInterval = refreshInterval;
    }

    public String getNumberOfShards() {
        return numberOfShards;
    }

    public void setNumberOfShards(String numberOfShards) {
        this.numberOfShards = numberOfShards;
    }

    public String getNumberOfReplicas() {
        return numberOfReplicas;
    }

    public void setNumberOfReplicas(String numberOfReplicas) {
        this.numberOfReplicas = numberOfReplicas;
    }

    @Override
    public String toString() {
        JSONObject settings = new JSONObject();
        if (StringUtils.isNotBlank(uuid)) {
            settings.put("uuid", uuid);
        }
        if (StringUtils.isNotBlank(refreshInterval)) {
            settings.put("refresh_interval", refreshInterval);
        }
        if (StringUtils.isNotBlank(numberOfShards)) {
            settings.put("number_of_shards", numberOfShards);
        }
        if (StringUtils.isNotBlank(numberOfReplicas)) {
            settings.put("number_of_replicas", numberOfReplicas);
        }
        return settings.toString();
    }
}
